const express = require('express');
let router = express.Router();
const {checkTokenMiddleware} = require('../js/middleware/checkTokenMiddleware.js')
const config = require("../js/config.js");

router.all('/', function (req, res, next) {
    // res.render('index', {title: 'Express'});
    // res.send("接口正常")
    res.success({data: "接口正常"});
});

let allRoutes = [];
allRoutes = [...allRoutes, ...require('./manage/manage.js')]

allRoutes.forEach(item => {
    if (item.checkLogin) {
        router[item.method](item.path, checkTokenMiddleware, item.controller);
    } else {
        router[item.method](item.path, item.controller);
    }
});

module.exports = router;
